<?php
/**
* 学生
* @date: 2017年8月11日 下午10:54:46
* @author: hxzlh
*/
namespace app\index\controller;
use think\Exception;
use app\index\model\Student as StudentModel;
use think\Request;

class Student extends Base 
{
    /**
     * XXX
     * 用户详情
     * @date: 2017年8月11日 下午11:43:46
     * @author: hxzlh
     * @throws Exception
     * @return: return
     */
    public function info() 
    {
        try{
            $this->checkLogin();
            $openid = Request::instance()->post('openid', null);
            if (empty($openid)) {
                throw new Exception('参数缺失', '102');
            }
            $data = StudentModel::where(['openid'=>$openid])->field(['id','name','phone'])->find();
            if (empty($data)) {
                throw new Exception('用户未关注,请关注');
            }
            $model = \think\Loader::model('Student','service');
            $data['course'] = $model->getCourse($data['id']) ? : [];
            $data['clbum'] = $model->getClbum($data['id']) ? : [];
            
            return parent::returnTrue($data);
        } catch (Exception $e) {
            $message['code'] = $e->getCode();
            $message['mes'] = $e->getMessage();
            return parent::returnFalse($message);
        }
    }
    
}
